package cn.kai.process.flow.node;

import cn.kai.process.flow.core.NodeContext;
import cn.kai.process.flow.core.Node;

import java.util.Objects;

/**
 * 循环节点
 Author: cKnight
 Date: 2025/1/23
 */
public class LoopNode implements Node {
    private Node loopNode;
    private Integer times;

    public LoopNode(Node node,Integer times){
        this.loopNode = node;
        this.times = Objects.isNull(times) || times.equals(0) ? 10 : times;
    }

    @Override
    public void execute(NodeContext context) {
        for (int i = 0; i < times; i++) {
            loopNode.exe(context);
        }
    }
}
